using System;
using System.Collections.Generic;
using System.Text;

namespace SmallBasicFun.TicTacToeGame
{
	public static class StringUtils
	{
		private static Random random = new Random();

		public static string DisplayGrid(int width, int height, Func<int, int, string> func)
		{
			StringBuilder b = new StringBuilder("  ");
			for (int x = 0; x < width; x++)
			{
				b.Append(String.Format("{0:0} ", x));
			}
			b.AppendLine();
			for (int y = 0; y < height; y++)
			{
				b.Append(String.Format("{0:0} ",y));
				for (int x = 0; x < width; x++)
				{
					b.Append(func(x, y)+ " ");
				}
				b.AppendLine();
			}
			return b.ToString();
		}

		public static T GetRandom<T>(this IList<T> items)
		{
			return items[random.Next(items.Count)];
		}
	}
}